//
//  com_tskiViewController.m
//  08tableview
//
//  Created by Rocky Xu on 12-8-20.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "com_tskiViewController.h"

@implementation com_tskiViewController
@synthesize listData;


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    NSArray *array = [[NSArray alloc]initWithObjects:@"aaa",@"basdf",@"ager",@"erjnf",@"ghjgh",@"rtwser",@"yyh",@"45t4",@"aaa",@"basdf",@"ager",@"erjnf",@"ghjgh",@"rtwser",@"yyh",@"45t4",@"aaa",@"basdf",@"ager",@"erjnf",@"ghjgh",@"rtwser",@"yyh",@"45t4",@"aaa",@"basdf",@"ager",@"erjnf",@"ghjgh",@"rtwser",@"yyh",@"45t4",@"aaa",@"basdf",@"ager",@"erjnf",@"ghjgh",@"rtwser",@"yyh",@"45t4",@"aaa",@"basdf",@"ager",@"erjnf",@"ghjgh",@"rtwser",@"yyh",@"45t4", nil];
    self.listData = array;
    [array release];
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
    self.listData = nil;
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

-(void) dealloc{
    [self.listData release];
    [super dealloc];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
	[super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
	[super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [self.listData count];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
    if(cell == nil){
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:SimpleTableIdentifier] autorelease];
    }
    
    UIImage *img = [UIImage imageNamed:@"star.png"];
    cell.imageView.image = img;
    UIImage *img2 = [UIImage imageNamed:@"star2.png"];
    cell.imageView.highlightedImage = img2;
    NSUInteger row = [indexPath row];
    cell.textLabel.text = [listData objectAtIndex:row];
    cell.textLabel.font = [UIFont boldSystemFontOfSize:50];
    cell.detailTextLabel.text = [[listData objectAtIndex:row] stringByAppendingFormat: @" detail"];
    return cell;
}

-(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSUInteger row = [indexPath row];
    return 1;
}

-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if(indexPath.row == 0) return nil;
    return indexPath;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 70;
}
@end
